<?php
require_once 'application/library/controller/gcLBasicAction.php';
require_once 'application/library/service/commService/gcProvService.php';
require_once 'application/modules/member/constant/member_constant_constant.php';
require_once 'application/modules/member/constant/member_constant_templatName.php';
require_once 'application/modules/member/services/member_services_memberListService.php';

/**
 * 客户一览
 * memberListController
 * @author    Soochow University
 * @version   1.0
 * @exclude   作  成  日：2011/04/07
 */
class member_memberListController extends gcLBasicAction{

    /**
     * objService
     */
    private $objService;

    /**
     * indexAction
     */
    public function indexAction(){
        $arrLabelId = array(
            "member_00001_Trust", "member_00001_NoTrust",
            "member_00001_Edit");
        $this->setLabelForJs($arrLabelId);
        $this->pvSetPageInfo();

        $objProv = new gcProvService();
        $arrProv = $objProv->getProvInfo();
        $this->gcView->arrProv=$arrProv;
        
        if ($this->getParam("ReturnFg")) {
            $arrParameter = sessionHelper::getPageData(member_constant_constant::MEMBER_LIST);
            $this->gcView->arrSession = $arrParameter;
            if ($this->getParam("ReturnFg") == "2") {
                $arrMessage[0] = $this->getMessage("INFO-00001");
            } else if ($this->getParam("ReturnFg") == "3") {
                $arrMessage[0] = $this->getMessage("INFO-00003");
            }
            $this->setErrorMsg($arrMessage);
        }
        if (empty($arrParameter)) {
            $arrParameter = array();
            $arrParameter["curPage"] = 1;
            $arrParameter["pageSize"] = 10;
        }
        sessionHelper::setPageData(member_constant_constant::MEMBER_LIST, $arrParameter);

        $this->objService=new member_services_memberListService();
        $this->gcView->intSum = $this->objService->pbGetMemberSum();

        $intCount = $this->objService->pbGetMemberDataCount($arrParameter);
        $objPager=$this->pagerInit($intCount, $arrParameter["curPage"], $arrParameter["pageSize"], pageSizeGroup::PAGE_SIZE_TEN, display::SHOW);
        $arrParameter["limit"] = $objPager->getLimit();
        $arrParameter["offset"] = $objPager->getOffset();

        $arrSearchData = $this->objService->pbGetMemberData($arrParameter);
        $arrSearchData = $objProv->getProvName($arrSearchData);

        $this->gcView->arrSearchData=$arrSearchData;
        $this->gcView->render(member_constant_templatName::MEMBER_LIST);
    }

    /**
     * searchAction
     */
    public function searchAction(){
        if($this->getRequest()->isXmlHttpRequest()){
            $strFlag = $this->getParam("Flag");
            if ($strFlag == "1") {
                $arrParameter = array();
                $arrParameter["pageSize"] = $this->getParam("pageSize");
                $arrParameter["MemberId"] = $this->getParam("MemberId");
                $arrParameter["MemberName"] = $this->getParam("MemberName");
                $arrParameter["SaleTp"] = $this->getParam("SaleTp");
                $arrParameter["ProvCode"] = $this->getParam("ProvCode");
                $arrParameter["Position"] = $this->getParam("Position");
                $arrParameter["MemberStatus"] = $this->getParam("MemberStatus");
                $arrParameter["MemberScale"] = $this->getParam("MemberScale", true);
                $arrParameter["CreateDateFrom"] = $this->getParam("CreateDateFrom");
                $arrParameter["CreateDateTo"] = $this->getParam("CreateDateTo");
                $arrParameter["ContractNo"] = $this->getParam("ContractNo");
                $arrParameter["Tel"] = $this->getParam("Tel");
                $arrParameter["Mobile"] = $this->getParam("Mobile");
                $arrParameter["Fax"] = $this->getParam("Fax");
                $arrParameter["Email"] = $this->getParam("Email");
                $arrParameter["OrderCountFrom"] = $this->getParam("OrderCountFrom");
                $arrParameter["OrderCountTo"] = $this->getParam("OrderCountTo");
                sessionHelper::setPageData(member_constant_constant::MEMBER_LIST, $arrParameter);
            } else {
                $arrParameter = sessionHelper::getPageData(member_constant_constant::MEMBER_LIST);
                $arrParameter["pageSize"] = $this->getParam("pageSize");
                $arrParameter["orderColumn"] = $this->getParam("orderColumn");
                $arrParameter["order"] = $this->getParam("order");
                sessionHelper::setPageData(member_constant_constant::MEMBER_LIST, $arrParameter);
            }
            $this->objService=new member_services_memberListService();
            $intCount = $this->objService->pbGetMemberDataCount($arrParameter);

            $objPager=$this->getPagerParam($intCount);
            $arrParameter["limit"] = $objPager->getLimit();
            $arrParameter["offset"] = $objPager->getOffset();
            $arrSearchData = $this->objService->pbGetMemberData($arrParameter);
            $objProv = new gcProvService();
            $arrSearchData = $objProv->getProvName($arrSearchData);

            $arrOutput = array(
                "count"      => $intCount,
                "curPage"    => $objPager->getCurPage(),
                "searchData" => $arrSearchData);
            if ($strFlag == "2") {
                $arrOutput["Parameter"] = $arrParameter;
            }
            jsonHelper::outPutJson($arrOutput);
        }else{
            echo 2;
        }
    }

    /**
     * pvSetPageInfo
     */
    private function pvSetPageInfo(){
        $this->gcView->title                        = $this->getLabel("member_00001_Title");
        $this->gcView->member_00001_Title         = $this->getLabel("member_00001_Title");
        $this->gcView->member_00001_Search        = $this->getLabel("member_00001_Search");
        $this->gcView->member_00001_Notice        = $this->getLabel("member_00001_Notice");
        $this->gcView->member_00001_NowSum        = $this->getLabel("member_00001_NowSum");
        $this->gcView->member_00001_Piece         = $this->getLabel("member_00001_Piece");
        $this->gcView->member_00001_Detail        = $this->getLabel("member_00001_Detail");
        $this->gcView->member_00001_Member      = $this->getLabel("member_00001_Member");
        $this->gcView->member_00001_MemberName  = $this->getLabel("member_00001_MemberName");
        $this->gcView->member_00001_SaleTp        = $this->getLabel("member_00001_SaleTp");
        $this->gcView->member_00001_Prov          = $this->getLabel("member_00001_Prov");
        $this->gcView->member_00001_PartSame      = $this->getLabel("member_00001_PartSame");
        $this->gcView->member_00001_Position      = $this->getLabel("member_00001_Position");
        $this->gcView->member_00001_MemberCreateDate    = $this->getLabel("member_00001_MemberCreateDate");
        $this->gcView->member_00001_Example       = $this->getLabel("member_00001_Example");
        $this->gcView->member_00001_ContractNo    = $this->getLabel("member_00001_ContractNo");
        $this->gcView->member_00001_Tel           = $this->getLabel("member_00001_Tel");
        $this->gcView->member_00001_Mobile        = $this->getLabel("member_00001_Mobile");
        $this->gcView->member_00001_Fax           = $this->getLabel("member_00001_Fax");
        $this->gcView->member_00001_Email         = $this->getLabel("member_00001_Email");
        $this->gcView->member_00001_OrderCount    = $this->getLabel("member_00001_OrderCount");
        $this->gcView->member_00001_Times         = $this->getLabel("member_00001_Times");
        $this->gcView->member_00001_Search        = $this->getLabel("member_00001_Search");
        $this->gcView->member_00001_SearchConditionClear  = $this->getLabel("member_00001_SearchConditionClear");
        $this->gcView->member_00001_Notice1       = $this->getLabel("member_00001_Notice1");
        $this->gcView->member_00001_Notice2       = $this->getLabel("member_00001_Notice2");
        $this->gcView->member_00001_NoLimit       = $this->getLabel("member_00001_NoLimit");
        $this->gcView->member_00001_Factory       = $this->getLabel("member_00001_Factory");
        $this->gcView->member_00001_Seller        = $this->getLabel("member_00001_Seller");
        $this->gcView->member_00001_Status        = $this->getLabel("member_00001_Status");
        $this->gcView->member_00001_Trust         = $this->getLabel("member_00001_Trust");
        $this->gcView->member_00001_NoTrust       = $this->getLabel("member_00001_NoTrust");
        $this->gcView->member_00001_Scale         = $this->getLabel("member_00001_Scale");
        $this->gcView->member_00001_More          = $this->getLabel("member_00001_More");
        $this->gcView->member_00001_Less          = $this->getLabel("member_00001_Less");
        $this->gcView->member_00001_People        = $this->getLabel("member_00001_People");
        $this->gcView->member_00001_LastOrderDate = $this->getLabel("member_00001_LastOrderDate");
        $this->gcView->member_00001_Edit          = $this->getLabel("member_00001_Edit");
        $this->gcView->member_00001_DataDownload  = $this->getLabel("member_00001_DataDownload");
        $this->gcView->member_00001_Download      = $this->getLabel("member_00001_Download");
        $this->gcView->member_00001_Add           = $this->getLabel("member_00001_Add");
        $this->gcView->member_00001_AddNotice     = $this->getLabel("member_00001_AddNotice");
    }
}
